{% extends "print_request/base_site.html" %}
{% load static %}

{% block extrastyle %}
{% endblock %}

{% block content %}
  <form method="post" action={{ response }}>
    {% csrf_token %}
    <p>
      <label>Title:</label>
      <text> {{ request.name }} </text>
    </p>
    <p>
      <label>Short description:</label>
      <text> {{ request.short_description }} </text>
    </p>
    <p>
      <label>Description:</label>
      <text> {{ request.description }} </text>
    </p>
    <p>
      <label>Publication date:</label>
      <text> {{ request.pub_date }} </text>
    </p>
    <p>
      <label>View:</label>
      <viewer id="span"></viewer>
    </p>
    <p>
      <div class="button-holder">
        <input type="submit" value="Print" />
      </div>
    </p>
  </form>
{% endblock %}

{% block extraend %}
  <script
    src="{% static "print_request/js/three.js" %}"
    type="text/javascript">
  </script>
  <script
    src="{% static "print_request/js/orbit_controls.js" %}"
    type="text/javascript">
  </script>
  <script type="text/javascript">
    function set_geometry()
    {
      var loader = new THREE.STLLoader();
      loader.addEventListener('load',
        function ( event )
        {

          var geometry = event.content;
          var material = new THREE.MeshNormalMaterial({
              ambient:   0x0055ff,
              color:     0x0055ff,
              specular:  0x111111,
              shininess: 200,
              side:      THREE.DoubleSide
            });
          mesh = new THREE.Mesh( geometry, material );
          scene.add( mesh );
        }
      );
      loader.load( '/media/{{ request.id }}-preview.stl' );
    }
  </script>
  <script
    src="{% static "print_request/js/STLLoader.js" %}"
    type="text/javascript">
  </script>
  <script
    src="{% static "print_request/js/display_preview.js" %}"
    type="text/javascript">
  </script>
{% endblock %}
